package com.batch.adance.migrate;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.stereotype.Repository;

import com.batch.adance.jdbc.Person;

@Repository
public class PersonDao {

	@Autowired
	private JdbcTemplate jdbcTemplate;
	private static final String SAVE_SQL = "insert into person_buf_bark02 ( `name`, `per_desc`, `sex`, `score`, `price`) values(?,?,?,?,?)";

	public void save(final Person item) {
		jdbcTemplate.update(SAVE_SQL, new PreparedStatementSetter() {
			public void setValues(PreparedStatement stmt) throws SQLException {
				stmt.setString(1, item.getName());
				stmt.setString(2, item.getPerDesc());
				stmt.setString(3, item.getSex());
				stmt.setFloat(4, item.getScore());
				stmt.setDouble(5, item.getPrice());
			}
		});
	}

}